#e
#Title[ŐuGhC`Normalv]
#Text[m[}ɂĂ͊ȒPH]
#ScriptVersion[2]

script_enemy_main {
 let img = "script\img\ExRumia.png";
 let name = "ŐuGhCv";

 @Initialize {
  CutIn(KOUMA, name, "", 0, 0, 0, 0);
  SetX(GetCenterX);
  SetY(GetCenterY - 120);
  SetLife(5000);
  SetScore(1000000);
  SetTimer(99);

  LoadGraphic(img);
  SetTexture(img);
  SetGraphicRect(64, 0, 128, 64);

  TMain;
 }

 @MainLoop {
  SetCollisionA(GetX, GetY, 24);
  SetCollisionB(GetX, GetY, 24);

  yield;
 }

 @DrawLoop {
  DrawGraphic(GetX, GetY);
 }

 @Finalize {
  DeleteGraphic(img);
 }

 //ȉ^XN(}CNXbh)

 task TMain {
  yield;

  TMove;
  TShot;
  TShot2; 
  //Ă
 }

 task TMove {
  yield;
 }

 task TShot {

  yield;

SetShotDirectionType(PLAYER);

  loop {
   loop(5) { yield; }
   CreateReflectShot(GetX, GetY, rand(2, 3), rand(0, 360), GREEN01, 0, 3);
  }
 }

 task TShot2 {
  let angle = 50;
  yield;

  loop {
   loop(2) {
    CreateReflectShot(GetX, GetY, 5, angle, GREEN23, 0, 2);
 angle += 360 / 10;
   
   }
   loop(2) { yield; }
  }
 }



 function wait(w) {
  loop(w) { yield; }
 }

 task CreateReflectShot(x, y, speed, angle, graphic, delay, limit) {
  //limit͔ˉ񐔂ł

  let obj = Obj_Create(OBJ_SHOT);

  Obj_SetPosition(obj, x, y);
  Obj_SetSpeed(obj, speed);
  Obj_SetAngle(obj, angle);
  ObjShot_SetGraphic(obj, graphic);
  ObjShot_SetDelay(obj, delay);
        
  loop(delay) { yield; }
        
  while(! Obj_BeDeleted(obj)) {

   if(Obj_GetX(obj) < GetClipMinX) {
    Obj_SetX(obj, GetClipMinX * 2 - Obj_GetX(obj));
    Obj_SetAngle(obj, 180 - Obj_GetAngle(obj));
    limit = 0;
   }

   if(Obj_GetX(obj) > GetClipMaxX) {
    Obj_SetX(obj, GetClipMaxX * 2 - Obj_GetX(obj));
    Obj_SetAngle(obj, 180 - Obj_GetAngle(obj));
    limit = 0;
   }

   if(Obj_GetY(obj) < GetClipMinY){
    Obj_SetY(obj, GetClipMinY * 2 - Obj_GetY(obj));
    Obj_SetAngle(obj, 360 - Obj_GetAngle(obj));
    limit += 3;
   }

   if(Obj_GetY(obj) > GetClipMaxY){
    Obj_SetY(obj, GetClipMaxY * 2 - Obj_GetY(obj));
    Obj_SetAngle(obj, 360 - Obj_GetAngle(obj));
    limit = 0;
   }

 

   if(limit <= 0) { break; }

   yield;
  }
 }

}